<template>
  <div>
    <div class="content">
      <div class="return" @click="close">
        <img class="img1" src="../../assets/img/return.png" alt="" />
        <p class="return-p">返回</p>
      </div>
      <div class="card1">
        <div class="card1-title">商户信息</div>
        <div class="card1-text">商户名称：{{ agent.name }}</div>
        <div class="card1-text">手机号：{{ agent.phone }}</div>
        <div class="card1-text">注册时间：{{ agent.time }}</div>
        <div class="card1-text">类型：{{ agent.roledec }}</div>
        <div class="card1-text">状态：{{ agent.statedec }}</div>
        <div class="card1-text">
          代金券金额：<span style="color: red" v-if="agent.voucher">{{ agent.voucher }}元</span>
        </div>
        <div class="card1-text">店铺名称：{{ agent.storename }}</div>
      </div>
      <div class="card" style="margin-top: 1rem">
        <div>
          <span class="card-span">赠送代金券：</span>
          <input
            style="margin-left: 0.4rem"
            class="input"
            type="number"
            v-model="money"
            placeholder="请输入金额"
          />
          <span class="card-span" style="margin-left: 0.1rem">元</span>
        </div>
        <!-- <div class="card-span1">用户余额剩余：{{ integral }}元</div> -->
      </div>
      <div class="sao" @click="sumbit">确认赠送</div>
      <van-dialog
        v-model="isSureShow"
        title="温馨提示"
        :show-cancel-button="false"
        :showConfirmButton="false"
        width="8.5rem"
      >
        <div style="padding: 0 0.5rem 0.5rem">
          <div class="tipsContent">
            赠送金额为
            <span style="color: red; font-weight: 600">{{ money }}</span>
            元,是否确认赠送。
          </div>
          <div
            style="
              display: flex;
              align-items: center;
              justify-content: space-around;
              padding: 0 0.5rem;
            "
          >
            <button class="cancelBtn" @click="cancel">
              <van-loading v-if="loadings" size="24px">赠送中...</van-loading>
              <span v-else>取消</span>
            </button>
            <button class="confirmBtn" @click="sureFn">
              <van-loading v-if="loadings" size="24px">赠送中...</van-loading>
              <span v-else>赠送</span>
            </button>
          </div>
        </div>
      </van-dialog>
    </div>
  </div>
</template>

<script>
import { quotaRecharge } from "@/api/fulfil.js";
export default {
  name:'supertubedit',
  data() {
    return {
      agent: {},
      store: {},
      ticket: {},
      list: [],
      money: "",
      isSureShow: false,
      loadings: false,
    };
  },
  created() {
   /*  this.agent = this.$route.query.item; */
  },
  mounted() {},
  activated() {
    this.agent = this.$route.query.item;
  },
  methods: {
    sumbit() {
      if (!this.money) {
        this.$Toast("赠送金额不能为空！");
      } else {
        this.isSureShow = true;
      }
    },
    sureFn() {
      this.loadings = true;
      quotaRecharge({
        adminid: localStorage.getItem("agentids"),
        agentid: localStorage.getItem("adminid"),
        money: this.money,
      })
        .then((res) => {
          if (res.data.code == 0) {
            this.$Toast("赠送成功！");
            this.money = "";
            this.isSureShow = false;
            setTimeout(() => {
              this.$router.go(-1);
            }, 2000);
          } else {
            this.$Toast(res.data.msg);
          }
          this.loadings = false;
        })
        .catch((error) => {
          this.loadings = false;
          console.log(error);
        });
    },
    cancel() {
      this.isSureShow = false;
    },

    close() {
      this.$router.go(-1);
    },
  },
};
</script>

<style scoped>
.content {
  overflow: hidden;
  width: 100%;
  min-height: 100vh;
  background: #e1f7fc;
}
.card1 {
  overflow: hidden;
  margin: 0.3rem auto 0;
  padding: 0 0.5rem 0.25rem 0.5rem;
  width: 84%;
  background: #fff;
  border-radius: 0.375rem;
}
.card1-title {
  margin-top: 0.2rem;
  font-size: 0.4125rem;
  font-weight: 600;
  color: #000;
}
.card1-text {
  margin: 0.25rem 0 0 0.2rem;
  font-size: 0.3125rem;
  font-weight: 600;
  color: #000;
}
.card1-text1 {
  margin: 0.25rem 0 0 0.2rem;
  font-size: 0.3125rem;
  font-weight: 600;
  color: #000;
  text-align: center;
}
.btn {
  margin-top: 0.6rem;
  display: flex; /* 应用Flex布局 */
  justify-content: space-between; /* 控制盒子之间的对齐方式 */
}
.btn1 {
  width: 2.4rem;
  height: 0.75rem;
  color: #000;
  text-align: center;
  line-height: 0.75rem;
  border-radius: 0.375rem;
  background-color: #3cc9e8;
}
.btn2 {
  width: 2.5rem;
  height: 0.75rem;
  line-height: 0.75rem;
  text-align: center;
  color: #000;
  border-radius: 0.375rem;
  background-color: #ffbe4c;
}
.sao {
  margin: 2rem auto 0;
  width: 60%;
  text-align: center;
  height: 1rem;
  line-height: 1rem;
  font-size: 0.35rem;
  border-radius: 0.5rem;
  background-color: #ffbe4c;
  font-weight: 600;
}
.card {
  overflow: hidden;
  margin: 0.3rem auto 0;
  width: 84%;
  border-radius: 0.375rem;
}
.input {
  margin-left: 0.1rem;
  margin-top: 0.2875rem;
  width: 60%;
  background: white;
  border: none;
  padding: 0.1875rem 0.25rem;
  border-radius: 0.25rem;
  border-inline: 2px solid transparent;
}
.card-span {
  font-size: 0.32rem;
  font-weight: 600;
}
.card-span1 {
  margin: 0.2rem 0 0 2.6rem;
  font-size: 0.32rem;
  font-weight: 600;
}
.img1 {
  display: inline-block;
  width: 27px;
  height: 48px;
  vertical-align: middle;
}
.return {
  margin: 20px 0 0 30px;
  font-size: 40px;
}
.return-p {
  margin-left: 20px;
  display: inline-block;
  vertical-align: middle;
}

.confirmBtn {
  margin-top: 0.5rem;
  width: 3rem;
  height: 1rem;
  background: linear-gradient(315deg, #4441ee 0%, #920ccc 100%);
  box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(0, 0, 0, 0.25);
  border-radius: 0.6rem;
  opacity: 1;
  color: #ffffff;
  border: none;
  font-size: 0.4rem;
}

.cancelBtn {
  margin-top: 0.5rem;
  width: 3rem;
  height: 1rem;
  background: #e2c7ff;
  box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(0, 0, 0, 0.25);
  border-radius: 0.6rem;
  opacity: 1;
  color: #6533d2;
  border: none;
  font-size: 0.4rem;
}

.van-dialog {
}

.tipsContent {
  margin: 0.5rem 0 1rem;
  display: inline-block;
  font-size: 0.4rem;
  font-family: PingFang SC-Medium, PingFang SC;
  font-weight: 500;
  color: #111111;
}
</style>